package com.common.frame.net;


import com.common.frame.mvp.base.BasePresenter;

import io.reactivex.SingleObserver;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;

public abstract class RequestCallBack<T> implements SingleObserver<T> {

    CompositeDisposable compositeDisposable;

    public RequestCallBack(CompositeDisposable compositeDisposable){
        this.compositeDisposable = compositeDisposable;
    }
    public RequestCallBack(BasePresenter basePresenter){
        this.compositeDisposable = basePresenter.mCompositeSubscription;
    }

    @Override
    public void onError(Throwable e) { }

    @Override
    public void onSubscribe(Disposable d) {
        if (compositeDisposable != null) compositeDisposable.add(d);
    }

    protected boolean errorShowToast(){
        return true;
    }
}
